<template>
	<view>
		<button @click="callStorage()">anliu1</button>
		<button @click="callgetStorage()">anliu2获取缓存</button>
		<button @click="callgetInfor()">anliu3获取字段</button>
		<button @click="callremove()" type="primary">anliu4删除</button>
		<button @click="callreclear()" type="warn">anliu5清空</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			callStorage(){
				 uni.setStorage({
					key:"username",
					data:"chuauyff",
					success(){
						console.log("存储username 成功回调");
					},
					fail() {
						console.log("存储username 回调失败");
					}
				})//{}表示对象 key:(字段是什么/变量命名)，data:(字段内容)
			},
			callgetStorage(){
				uni.getStorage({
					key:"userName",
					success:function(result) {
						console.log("获取本地缓存成功: result.data:"+result.data)
					},
					fail:function(result){
						console.error("获取本地缓存失败:"+JSON.stringify(result));
						console.error("获取本地缓存失败:"+ result.errMsg);
						
					}
				})
			},
			callgetInfor(){
				console.log("callgetInfor-->");
				uni.getStorageInfo({
					success:function(result){
						console.log("callgetInfor-->"+JSON.stringify(result));
						console.log("callgetInfor-->"+result.keys);
						console.log("callgetInfor-->"+JSON.stringify(result));
					}
				})
			},
			
		}
	}
</script>

<style>

</style>
